$(function () {
    let productid = getUrl('productid');
    productid = productid || 2;
    init();
    function init() {
        getData();
        getComment();
    }
    function eventList() {

    }
    // 根据商品id获取对应信息
    function getData() {
        $.get('http://193.112.55.79:9090/api/getproduct?productid=' + productid, function (result) {
            let data = result.result[0]
            $('.pro_info_img').html(data.productImg);
            $('.pro_info_title').html(data.productName);
            $('.bjb_item').html(data.bjShop);

        })
    }
    // 根据商品id获取对应评论
    function getComment() {
        $.get('http://193.112.55.79:9090/api/getproductcom?productid=' + productid, function (result) {
            let data = result.result
            console.log(result.result);
            let html = template('contentTp',{data:data})
            $('.bijia_comment_com').html(html);

        })
    }

    function getUrl(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
})